Skip to content

send old version memoryQueue's stale activation to queueManager when update action #5228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ningyougang
Copy link
Contributor

@ningyougang ningyougang commented Apr 28, 2022

  • Send old version memoryQueue's stale activation to queueManager when update action if doesn't exist old version container.

This is bug, if doesn't fix, the activation will be failed as below

activation processing is not initiated for 60000 ms
  • Add exponential delay for container creation retry

This is enhance point, during retry,

  • wait 100.milliseconds for 0th retry
  • wait 200.milliseconds for 1th retry
  • wait 400.milliseconds for 2th retry
  • wait 800.milliseconds for 3th retry
  • wait 1600.milliseconds for 4th retry
  • change scheduler's scheduler_inProgressJobRetentionSecond to scheduler_inProgressJobRetention

Description

Related issue and scope

  • I opened an issue to propose and discuss this change (#????)

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Scheduler
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

When old container doesn't exist
@@ -97,7 +96,7 @@ class CreationJobManager(feedFactory: (ActorRefFactory, String, String, Int, Arr
if (retryCount >= retryLimit || !error.exists(ContainerCreationError.whiskErrors.contains)) {
logging.error(
this,
s"[$creationId] Failed to create container $retryCount/$retryLimit times for $cause. Finished creation")
s"[$action] [$creationId] Failed to create container $retryCount/$retryLimit times for $cause. Finished creation")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it easy to debug in future maybe.

@codecov-commenter
Copy link

codecov-commenter commented Apr 28, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 72.98%. Comparing base (3e3414c) to head (f7f8fff).
Report is 157 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5228       +/-   ##
===========================================
+ Coverage   44.53%   72.98%   +28.44%     
===========================================
  Files         238      238               
  Lines       13957    13965        +8     
  Branches      570      576        +6     
===========================================
+ Hits         6216    10192     +3976     
+ Misses       7741     3773     -3968     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -561,6 +561,20 @@ class MemoryQueue(private val etcdClient: EtcdClient,
// let QueueManager know this queue is no longer in charge.
context.parent ! staleQueueRemovedMsg

if (queue.size > 0) {
// if doesn't exist old container to pull old memoryQueue's activation, complete the activation directly
if (containers.size == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to consider containers being created(in-progress containers).
And it's worth discussing but IIRC, in our downstream, we decided to promote the old version of activations to the latest one rather than just completing them with errors.
If we do this, I think QueueManager should act in the same way for stale activations.

Copy link
Contributor Author

@ningyougang ningyougang May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding I think we need to consider containers being created(in-progress containers).
I think have no need to consider in-progress containers during action update in this case, because

So here, i think just consider if (containers.size == 0) is enough.

Regarding

And it's worth discussing but IIRC, in our downstream, we decided to promote the old version of activations to the latest one rather than just completing them with errors.
If we do this, I think QueueManager should act in the same way for stale activations.

when this case happens and have no existing old version container, just send the stale activation to queueManager to schedule to new version memoryQueue, and the activations will be fetched by new version container.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so this is to promote the activation revision by sending them to QueueManager.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

@ningyougang ningyougang force-pushed the complete-old-activation-when-update-action branch from 3185af0 to 7715ad5 Compare May 5, 2022 08:13
@ningyougang ningyougang changed the title Complete old activation when update action send old version memoryQueue's stale activation to queueManager when update action May 5, 2022
probe.expectMsg(Transition(fsm, state, Removing))

fsm ! QueueRemovedCompleted

// queue should not be terminated as there is an activation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why these lines are removed? since there is a container in https://github.com/apache/openwhisk/pull/5228/files#diff-4b5788222d7949baf4e09b570e4fa49d3fa79e5432ff50c798b04353758c8d4aR1539, I think message should not be sent to QueueManager?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, fixed.

@@ -1496,6 +1497,7 @@ class MemoryQueueFlowTests
// queue should not be terminated as there is an activation
Thread.sleep(gracefulShutdownTimeout.toMillis)

fsm.underlyingActor.containers = Set(testContainerId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding this line covers case that there is still a container for old queue, but does not cover case that there is no container for old queue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated accordingly.

memoryQueue.creationIds.size shouldBe 1
// the monit actor in memoryQueue may decide to create a container
memoryQueue.creationIds.size should be >= 1
memoryQueue.creationIds.size should be <= 2
Copy link
Contributor Author

@ningyougang ningyougang May 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to this codes: https://github.com/apache/openwhisk/blob/master/core/scheduler/src/main/scala/org/apache/openwhisk/core/scheduler/queue/MemoryQueue.scala#L908
Above #L908 code is good due to store the inprogressId to etcd needs some time, so when containerCreationMessage created, need to add that creationId to creationIds in advance.

This test case may not stable, e.g. due to the creationId(testId1) doesn't keep consistent with CreationId.generate(), if the monit actor decide to create a container very quickly, this test case would be failed.

So here, make it stable.

@@ -554,7 +554,7 @@ class QueueManagerTests
mockConsumer,
QueueManagerConfig(maxRetriesToGetQueue = 2, maxSchedulingTime = 10 seconds)))

queueManager ! activationMessage
queueManager ! activationMessage.copy(transid = TransactionId(messageTransId.meta.copy(start = Instant.now())))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this test case more stable

@@ -829,6 +834,23 @@ class MemoryQueue(private val etcdClient: EtcdClient,
}
}


private def handleStaleActivationsWhenUpdateAction(queueManager: ActorRef): Unit = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private def handleStaleActivationsWhenUpdateAction(queueManager: ActorRef): Unit = {
private def handleStaleActivationsWhenActionUpdated(queueManager: ActorRef): Unit = {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the method name accordingly.

@@ -561,6 +561,20 @@ class MemoryQueue(private val etcdClient: EtcdClient,
// let QueueManager know this queue is no longer in charge.
context.parent ! staleQueueRemovedMsg

if (queue.size > 0) {
// if doesn't exist old container to pull old memoryQueue's activation, complete the activation directly
if (containers.size == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so this is to promote the activation revision by sending them to QueueManager.

@ningyougang ningyougang merged commit 37f1f99 into apache:master May 9, 2022
@ningyougang
Copy link
Contributor Author

I will merge this pr due to this can make some test cases more stable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants